package com.nameless.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.nameless.entity.Shop;
import com.nameless.service.ShopService;
import com.nameless.vo.Result;
import com.nameless.vo.ShopVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author keluoyisi
 * @program: car-parent
 * @description: 商店接口
 * @date 2023-02-27 17:22:49
 */
@RestController
@RequestMapping("/car/shop")
public class ShopController {
    @Autowired
    private ShopService shopService;

    @PostMapping("/areaIdShop")
    public Result areaIdShop(Integer areaId){
        System.out.println(areaId);
        return shopService.areaIdShop(areaId);
    }

    @PostMapping("/queryAllByParam")
    public Result queryAllByParam(@RequestBody ShopVo shopVo){
        return shopService.queryAllByParam(shopVo);
    }

    @PostMapping("/insert")
    public Result insertShop(@RequestBody Shop shop){
        return shopService.insertShop(shop);
    }

    @PostMapping("/update")
    public Result updateShop(@RequestBody Shop shop){
        return shopService.updateShop(shop);
    }

    @DeleteMapping("/deleteById")
    public Result deleteById(Integer id){
        return shopService.deleteById(id);
    }

    @GetMapping("/selectShopAll")
    public Result selectShopAll(){
        List<Shop> shops = shopService.selectShopAll();
        return new Result(200,"成功",shops);
    }
    @RequestMapping("/getShopById/{shopId}")
    public Shop getShopById(@PathVariable Integer shopId){
        LambdaQueryWrapper<Shop> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Shop::getId,shopId);
        return shopService.getOne(queryWrapper);
    }
}
